local NearPlayerCell = class("NearPlayerCell")

function NearPlayerCell:ctor()
end

function NearPlayerCell:start()
    self._btnChat.onClick:AddListener(handler(self, self._onBtnChatClick))
    self._btnTeam.onClick:AddListener(handler(self, self._onBtnTeamClick))
end

function NearPlayerCell:updateUI(data)
    self._data = data
    self._textName.text = data.userName
end

function NearPlayerCell:_onBtnChatClick()
    if not self._data then
        return
    end
    local chat = require("view.chat.ChatView").new(self._data)
end

function NearPlayerCell:_onBtnTeamClick()
    if not self._data then
        return
    end
    printDebug("NearPlayerCell:_onBtnTeamClick")
    G_UserData:getTeamGroup():c2sInviteTeam(self._data.userId)
end

return NearPlayerCell
